
//boudning line is alpha1, gama1

	//1

	for (a[0]=0; a[0] <= gama[4]; a[0] += delta) { 
		for (a[1]=0; a[1] <= beta[1][2]; a[1] += delta) { 
			for (a[2]=0; a[2] <= beta[2][3]; a[2] += delta) {

				tmpmin = alpha[2]*alpha[3] +

					a[2]*(alpha[3])+(beta[2][3]-a[2])*alpha[2];

				if (tmpmin < edges) {edges = tmpmin;dir=1;part1=a[0];part2=a[1];}
			}
		}
	}

	//2
	for (a[0]=0; a[0] <= alpha[2]; a[0] += delta) { 
		for (a[1]=0; a[1] <= beta[1][2]; a[1] += delta) { 
			for (a[2]=0; a[2] <= beta[2][3]; a[2] += delta) {

				tmpmin = a[0]*alpha[3] + (alpha[2]-a[0])*alpha[4] +

					a[0]*(beta[2][3]-a[2])+(a[2])*alpha[3] + (alpha[2]-a[0])*beta[2][4];

				if (tmpmin < edges) {edges = tmpmin;dir=2;part1=a[0];part2=a[1];}
			}
		}
	}

	//3
	for (a[0]=0; a[0] <= alpha[2]; a[0] += delta) { 
		for (a[1]=0; a[1] <= beta[1][2]; a[1] += delta) { 
			for (a[2]=0; a[2] <= beta[2][4]; a[2] += delta) {

				tmpmin = a[0]*alpha[3] + (alpha[2]-a[0])*alpha[4] +

					(alpha[2]-a[0])*a[2] + (beta[2][4]-a[2])*alpha[4] + a[0]*(beta[2][3]); 

				if (tmpmin < edges) {edges = tmpmin;dir=3;part1=a[0];part2=a[1];}
			}
		}
	}

		
	//4
	for (a[0]=0; a[0] <= gama[3]; a[0] += delta) { 
		for (a[1]=0; a[1] <= beta[1][2]; a[1] += delta) { 
			for (a[2]=0; a[2] <= beta[2][4]; a[2] += delta) {

				tmpmin = alpha[2]*alpha[4]+
					alpha[2]*a[2]+(beta[2][4]-a[2])*alpha[4]; 

				if (tmpmin < edges) {edges = tmpmin;dir=4;part1=a[0];part2=a[1];}
			}
		}
	}


	//5
	for (a[0]=0; a[0] <= gama[3]; a[0] += delta) { 
		for (a[1]=0; a[1] <= beta[1][4]; a[1] += delta) { 
			for (a[2]=0; a[2] <= beta[2][4]; a[2] += delta) {

				tmpmin = alpha[2]*alpha[4]+
					alpha[2]*a[2]+(beta[2][4]-a[2])*alpha[4]; 

				if (tmpmin < edges) {edges = tmpmin;dir=5;part1=a[0];part2=a[1];}
			}
		}
	}


	//6

	for (a[0]=0; a[0] <= alpha[4]; a[0] += delta) { 
		for (a[1]=0; a[1] <= beta[1][4]; a[1] += delta) { 
			for (a[2]=0; a[2] <= beta[2][4]; a[2] += delta) {

				tmpmin = alpha[2]*a[0]+(alpha[4]-a[0])*alpha[3] +
					alpha[2]*a[2] + (beta[2][4]-a[2])*(a[0]) + beta[3][4]*(alpha[4]-a[0]) ; 

				if (tmpmin < edges) {edges = tmpmin;dir=6;part1=a[0];part2=a[2];}
			}
		}
		}


	//7 


	for (a[0]=0; a[0] <= alpha[4]; a[0] += delta) { 
		for (a[1]=0; a[1] <= beta[1][4]; a[1] += delta) { 
			for (a[2]=0; a[2] <= beta[3][4]; a[2] += delta) {

				tmpmin = alpha[2]*a[0]+(alpha[4]-a[0])*alpha[3] +
					beta[2][4]*a[0]  + a[2]*(alpha[4]-a[0]) +  (beta[3][4]-a[2])*alpha[3]; 

				if (tmpmin < edges) {edges = tmpmin;dir=7;part1=a[0];part2=a[2];}
			}
		}
		}


	//8

	for (a[0]=0; a[0] <= gama[2]; a[0] += delta) { 
		for (a[1]=0; a[1] <= beta[1][4]; a[1] += delta) { 
			for (a[2]=0; a[2] <= beta[3][4]; a[2] += delta) {

				tmpmin = alpha[4]*alpha[3]+
					a[2]*alpha[4]+(beta[3][4]-a[2])*alpha[3]; 

				if (tmpmin < edges) {edges = tmpmin;dir=8;part1=a[0];part2=a[2];}
			}
		}
		}

	//9

	for (a[0]=0; a[0] <= gama[2]; a[0] += delta) { 
		for (a[1]=0; a[1] <= beta[1][3]; a[1] += delta) { 
			for (a[2]=0; a[2] <= beta[3][4]; a[2] += delta) {

				tmpmin = alpha[4]*alpha[3]+
					a[2]*alpha[4]+(beta[3][4]-a[2])*alpha[3]; 

				if (tmpmin < edges) {edges = tmpmin;dir=9;part1=a[0];part2=a[2];}
			}
		}
		}

	//10

	for (a[0]=0; a[0] <= alpha[3]; a[0] += delta) { 
		for (a[1]=0; a[1] <= beta[1][3]; a[1] += delta) { 
			for (a[2]=0; a[2] <= beta[3][4]; a[2] += delta) {

				tmpmin = alpha[4]*a[0]+(alpha[3]-a[0])*alpha[2]+

					alpha[4]*a[2] + a[0]*(beta[3][4]-a[2]) + (alpha[3]-a[0])*(beta[2][3]); 

				if (tmpmin < edges) {edges = tmpmin;dir=10;part1=a[0];part2=a[2];}
			}
		}
		}

	//11

	for (a[0]=0; a[0] <= alpha[3]; a[0] += delta) { 
		for (a[1]=0; a[1] <= beta[1][3]; a[1] += delta) { 
			for (a[2]=0; a[2] <= beta[2][3]; a[2] += delta) {

				tmpmin = alpha[4]*a[0]+(alpha[3]-a[0])*alpha[2]+

					beta[3][4]*a[0] + (alpha[3]-a[0])*a[2] + alpha[2]*(beta[2][3]-a[2]); 

				if (tmpmin < edges) {edges = tmpmin;dir=11;part1=a[0];part2=a[2];}
			}
		}
		}

	//12

	for (a[0]=0; a[0] <= gama[4]; a[0] += delta) { 
		for (a[1]=0; a[1] <= beta[1][3]; a[1] += delta) { 
			for (a[2]=0; a[2] <= beta[2][3]; a[2] += delta) {

				tmpmin = alpha[2]*alpha[3]+
					alpha[2]*(a[2])+(beta[2][3]-a[2])*alpha[3]; 

				if (tmpmin < edges) {edges = tmpmin;dir=12;part1=a[0];part2=a[2];}
			}
		}
		}




	